package com.sleeping.mall.common.utils.result;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 返回分页列表公用DTO
 *
 * @author ChenDong
 * @date 2018/5/11
 */
public class ResponsePageList<T> implements Serializable {

    private boolean success = true;

    private String msg = "";

    private int page;

    private long total;

    private List<T> obj;

    public ResponsePageList(ResponseWrapper<T> responseWrapper) {
        this.success = responseWrapper.isSuccess();
        this.msg = responseWrapper.getMsg();
        List<T> obj = new ArrayList<>();
        obj.add(responseWrapper.getObj());
        this.obj = obj;
        this.page = 0;
        this.total = obj.size();
    }

    public ResponsePageList(List<T> data) {
        this.obj = data;
    }

    public ResponsePageList() {
    }

    public int getPage() {
        return page;
    }

    public ResponsePageList<T> setPage(int page) {
        this.page = page;
        return this;
    }

    public long getTotal() {
        return total;
    }

    public ResponsePageList<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public List<T> getData() {
        return obj;
    }

    public ResponsePageList<T> setData(List<T> data) {
        this.obj = data;
        return this;
    }

    public boolean isSuccess() {
        return success;
    }

    public ResponsePageList<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public ResponsePageList<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }
}
